import { usePageResponseSuccess } from '~/utils/response';

export default eventHandler((event) => {
  const query = getQuery(event);
  const {
    page = 1,
    pageSize = 10,
    keyword = '',
    businessType = '',
    status = '',
  } = query;

  const businessResources = [
    {
      id: '1',
      name: '豪华套房',
      code: 'ROOM-001',
      businessType: 'HOTEL',
      category: 'PHYSICAL',
      status: 'ACTIVE',
      description: '五星级酒店豪华套房，配备完整设施',
      location: 'A栋15层',
      capacity: 4,
      price: 1280,
      createTime: '2024-01-01 00:00:00',
      updateTime: '2024-01-01 00:00:00',
    },
    {
      id: '2',
      name: '温泉池',
      code: 'SPA-001',
      businessType: 'HOT_SPRING',
      category: 'PHYSICAL',
      status: 'ACTIVE',
      description: '天然温泉池，温度38-42度',
      location: '温泉区A区',
      capacity: 20,
      price: 180,
      createTime: '2024-01-01 00:00:00',
      updateTime: '2024-01-01 00:00:00',
    },
    {
      id: '3',
      name: 'VIP包间',
      code: 'REST-001',
      businessType: 'RESTAURANT',
      category: 'PHYSICAL',
      status: 'ACTIVE',
      description: '高档餐厅VIP包间，可容纳8-12人',
      location: '餐厅2楼',
      capacity: 12,
      price: 500,
      createTime: '2024-01-01 00:00:00',
      updateTime: '2024-01-01 00:00:00',
    },
    {
      id: '4',
      name: '宠物诊疗室',
      code: 'PET-001',
      businessType: 'PET_MEDICAL',
      category: 'PHYSICAL',
      status: 'ACTIVE',
      description: '专业宠物诊疗室，配备先进设备',
      location: '医疗区1楼',
      capacity: 1,
      price: 200,
      createTime: '2024-01-01 00:00:00',
      updateTime: '2024-01-01 00:00:00',
    },
    {
      id: '5',
      name: '高级技师',
      code: 'STAFF-001',
      businessType: 'HOT_SPRING',
      category: 'HUMAN',
      status: 'ACTIVE',
      description: '专业按摩技师，5年经验',
      location: '技师部',
      capacity: 1,
      price: 150,
      createTime: '2024-01-01 00:00:00',
      updateTime: '2024-01-01 00:00:00',
    },
  ];

  // 模拟搜索过滤
  let filteredResources = businessResources;

  if (keyword) {
    filteredResources = filteredResources.filter(
      (resource) =>
        resource.name.includes(keyword as string) ||
        resource.code.includes(keyword as string),
    );
  }

  if (businessType) {
    filteredResources = filteredResources.filter(
      (resource) => resource.businessType === businessType,
    );
  }

  if (status) {
    filteredResources = filteredResources.filter(
      (resource) => resource.status === status,
    );
  }

  return usePageResponseSuccess(page, pageSize, filteredResources);
});
